package com.lkd.http.controller;

import com.lkd.entity.ChannelEntity;
import com.lkd.http.controller.vo.ChannelConfigReq;
import com.lkd.service.ChannelService;
import com.lkd.vo.ChannelVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/channel")
public class ChannelController {

    @Autowired
    private ChannelService channelService;


    /*
    * 货道列表
    * */
    @GetMapping("/channelList/{innerCode}")
    public List<ChannelEntity> channelList(@PathVariable("innerCode") String innerCode){
        return channelService.channelList(innerCode);
    }


    /*
    * 货道配置
    * */
    @PutMapping("/channelConfig")
    public void channelConfig(@RequestBody ChannelConfigReq channelConfigReq){
        channelService.channelConfig(channelConfigReq);
    }

    /*
    * 商品在售货机中所在货道
    * */
    @GetMapping("/hasCapacity/{innerCode}/{skuId}")
    public ChannelVO hasCapacity(@PathVariable(name = "innerCode") String innerCode,
                                 @PathVariable(name="skuId") Long skuId){
        return channelService.hasCapacity(innerCode,skuId);
    }
}
